package sword_to_1;

import node.TreeNode;

public class LeeCode_27 {
    public static void main(String[] args) {

    }
    private static TreeNode mirrorTree(TreeNode root) {
        if (root == null){
            return null;
        }
        TreeNode ans = new TreeNode(root.val);
        dfs(ans, root);
        return ans;
    }
    private static void dfs(TreeNode node, TreeNode root){
        if (root.left != null){
            node.right = new TreeNode(root.left.val);
            dfs(node.right, root.left);
        }
        if (root.right != null){
            node.left = new TreeNode(root.right.val);
            dfs(node.left, root.right);
        }
    }
}
